/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-04-01 10:09:57
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-04-21 10:49:37
 * @FilePath: \algorithm\algorithm-training\lqb\acwing4_1.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
#include <bitset>
using namespace std;
using ull = unsigned long long;
using i128 = __int128_t;
//inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
#define int long long

const int N = 1e5+10;

struct Node {
    int nu;
    int cnt;
};
bool cmp(Node a,Node b) {
    return a.nu < b.nu;
}


void solve()
{  
    int n;
    cin >> n;

    vector<int>arr(n + 10);
    vector<int>brr(n + 10);
    for(int i = 1; i <= n; i ++) cin >> arr[i];
    for(int i = 1; i <= n; i ++) cin >> brr[i];
    vector<Node>v(n + 10);
    for(int i = 1; i <= n; i ++)
    {
        arr[i] = arr[i] * i;
        v[i].cnt = i;
        v[i].nu = arr[i];
    }
    sort(v.begin() + 1,v.begin() + 1 + n,cmp);
    vector<int>ans(n + 10);
    sort(brr.begin() + 1,brr.begin() + 1 + n);

    for(int i = 1; i <= n; i ++)
    {
        int nu = v[i].cnt;
        ans[nu] = brr[i];
    }

    for(int i = 1; i <= n; i ++)
    {
        cout << ans[i] << " ";
    }
}
signed main()
{
    int t = 1;
    //cin >> t;
    while(t --)
    {
        solve();
    }
}
